package com.kcl.dfss;

import com.kcl.dfss.utils.ApplicationData;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class UpdateAppActivity extends Activity {

	private LinearLayout back = null;
	private TextView text_version,text_newversion,text_appcontent;
	private Button btn_downapp;
	private String url = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_update_app);
		
		back = (LinearLayout) findViewById(R.id.update_app_back);
		text_version = (TextView) findViewById(R.id.text_version);
		text_newversion = (TextView) findViewById(R.id.text_newversion);
		text_appcontent = (TextView) findViewById(R.id.text_appcontent);
		btn_downapp = (Button) findViewById(R.id.btn_downapp);
		
		Intent intent = getIntent();
		text_version.setText("当前版本:"+ApplicationData.app_version);
		text_newversion.setText("新  版  本:"+intent.getStringExtra("server_version"));
		text_appcontent.setText("新版本介绍:"+"\n"+intent.getStringExtra("appcontent"));
		
		url = intent.getStringExtra("appurl");
		
		back.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		btn_downapp.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Uri uri = Uri.parse("http://"+url);
				Intent intentView = new Intent();
				intentView.setAction(Intent.ACTION_VIEW);
				intentView.setData(uri);
				//加下面这句话就是启动系统自带的浏览器打开上面的网址，  不加下面一句话，  如果你有多个浏览器，就会弹出让你选择某一浏览器， 然后该浏览器就会打开该网址...............
				//intentView.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
				startActivity(intentView);
			}
		});
	}

}
